﻿<UserControl x:Class="Menafrinet.View.Controls.DataEntryPanel"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:view="clr-namespace:Menafrinet.View"
             xmlns:p="clr-namespace:Menafrinet.View.Properties"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:controls="clr-namespace:Menafrinet.View.Controls"
             mc:Ignorable="d" 
             SizeChanged="UserControl_SizeChanged"
             d:DesignHeight="300" d:DesignWidth="800">
    <Grid x:Name="grdHome" VerticalAlignment="Stretch" Height="Auto" Style="{StaticResource GradientGrid}" >
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="688*"></ColumnDefinition>
            <ColumnDefinition Width="112*" />
        </Grid.ColumnDefinitions>

        <Grid x:Name="grdMain" Margin="8,0" Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type Window}}, Path=ActualHeight}" Grid.ColumnSpan="2">

            <Grid x:Name="grdRecordsLayout">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>

                <StackPanel>
                    <TextBlock Grid.Row="0" Grid.ColumnSpan="4" Style="{StaticResource PageHeaderTextBlockStyle}" Text="Data Entry and Management" />
                    <StackPanel Height="20" />
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto" />
                            <ColumnDefinition Width="*" />
                            <ColumnDefinition Width="Auto" />
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" FontSize="14">Search</TextBlock>
                        <TextBox x:Name="txtSearch" Grid.Column="1" FontSize="14" Margin="10, 0, 10, 0" Text="{Binding Path=SearchString,Mode=TwoWay,
            UpdateSourceTrigger=PropertyChanged}" />
                        <!--<Button x:Name="btnSearch" Width="64" Height="24" Grid.Column="2" Style="{StaticResource FlatButtonStyle}" Command="{Binding Path=Search}">
                                <Path Width="18.1464" Height="18.1465" Stretch="Fill" Fill="White" Data="F1 M 42.5,22C 49.4036,22 55,27.5964 55,34.5C 55,41.4036 49.4036,47 42.5,47C 40.1356,47 37.9245,46.3435 36,45.2426L 26.9749,54.2678C 25.8033,55.4393 23.9038,55.4393 22.7322,54.2678C 21.5607,53.0962 21.5607,51.1967 22.7322,50.0251L 31.7971,40.961C 30.6565,39.0755 30,36.8644 30,34.5C 30,27.5964 35.5964,22 42.5,22 Z M 42.5,26C 37.8056,26 34,29.8056 34,34.5C 34,39.1944 37.8056,43 42.5,43C 47.1944,43 51,39.1944 51,34.5C 51,29.8056 47.1944,26 42.5,26 Z "/>
                        </Button>-->
                    </Grid>
                    <!--<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0, 10, 0, 0">
                        <StackPanel Orientation="Horizontal">
                            <Rectangle Fill="{StaticResource RowInvalidEPIDBackgroundBrush}" Stroke="Black" StrokeThickness="1" Width="16" Height="16" />
                            <Label>= invalid EPID</Label>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <Rectangle Fill="{StaticResource RowDuplicateBackgroundBrush}" Stroke="Black" StrokeThickness="1" Width="16" Height="16" />
                            <Label>= duplicate record</Label>
                        </StackPanel>

                        <StackPanel Orientation="Horizontal">
                            <Rectangle Fill="{StaticResource RowDisableBackgroundBrush}" Stroke="Black" StrokeThickness="1" Width="16" Height="16" />
                            <Label>= deleted record</Label>
                        </StackPanel>
                    </StackPanel>-->
                </StackPanel>

                <StackPanel x:Name="panelRecords" Margin="0,5,0,0" Grid.Row="2" Grid.IsSharedSizeScope="True">
                        <Border Background="{StaticResource gridHeaderBrush}">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition/>
                                    <ColumnDefinition Width="Auto"/>
                                </Grid.ColumnDefinitions>

                            <StackPanel Orientation="Horizontal">
                                <TextBlock Margin="5" FontWeight="SemiBold" FontSize="16" Foreground="White" Text="{x:Static p:Resources.Records}"></TextBlock>

                                <TextBlock Margin="5, 5, 0, 5" FontWeight="SemiBold" FontSize="16" Foreground="White">(</TextBlock>
                                <TextBlock x:Name="tblockRecordCount" Margin="0, 5, 0, 5" FontWeight="SemiBold" FontSize="16" Foreground="White" Text="{Binding Path=FilteredCaseCollection.Count}"></TextBlock>
                                <TextBlock Margin="0, 5, 5, 5" FontWeight="SemiBold" FontSize="16" Foreground="White">)</TextBlock>
                            </StackPanel>

                            <StackPanel Margin="2" Orientation="Horizontal" Grid.Column="1">
                                    <Button x:Name="btnNewRecord" Margin="1" Width="115" Height="18" Style="{StaticResource FlatButtonStyle}" Click="btnNewRecord_Click">
                                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{x:Static p:Resources.NewRecord}"></TextBlock>
                                    </Button>

                                <Button x:Name="btnPrintRecords" Margin="1" Width="115" Height="18" Style="{StaticResource FlatButtonStyle}" Click="btnPrintRecords_Click">
                                    <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" Text="{x:Static p:Resources.Print}"></TextBlock>
                                </Button>
                            </StackPanel>
                            </Grid>
                        </Border>
                    <DataGrid x:Name="dgRecords" Height="100"
                      ItemsSource="{Binding Path=FilteredCaseCollection, IsAsync=True, FallbackValue=...}"
                  VirtualizingStackPanel.IsVirtualizing="True"
                  VirtualizingStackPanel.VirtualizationMode="Recycling"
                              MouseDoubleClick="dgRecords_MouseDoubleClick"
                          AutoGenerateColumns="False">
                        <DataGrid.Columns>
                            <DataGridTemplateColumn Header="{x:Static p:Resources.ColHeaderStatus}">
                                <DataGridTemplateColumn.CellTemplate>
                                    <DataTemplate>
                                        <controls:CaseStatusRowDisplay DataContext="{Binding}" />
                                    </DataTemplate>
                                </DataGridTemplateColumn.CellTemplate>
                            </DataGridTemplateColumn>
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderEPID}" Binding="{Binding EPID}" IsReadOnly="True"></DataGridTextColumn>
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderLastName}" Binding="{Binding LastName}" IsReadOnly="True"></DataGridTextColumn>
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderFirstName}" Binding="{Binding FirstName}" IsReadOnly="True"></DataGridTextColumn>
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderSex}" Binding="{Binding Sex}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderAge}" Binding="{Binding Age}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderHealthFacility}" Binding="{Binding HealthFacility}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderReportingDistrict}" Binding="{Binding DistrictReporting}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderYear}" Binding="{Binding Year}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderEpiWeek}" Binding="{Binding EpiWeek}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderLPPerformed}" Binding="{Binding LPPerformed}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderFinalLabResult}" Binding="{Binding FinalLabResult}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderClassification}" Binding="{Binding Classification}" IsReadOnly="True" />
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderOutcome}" Binding="{Binding Outcome}" IsReadOnly="True" />

                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderCreatedOn}" Binding="{Binding DateRecordCreated, StringFormat='dd/MM/yyyy'}" IsReadOnly="True"></DataGridTextColumn>
                            <DataGridTextColumn Header="{x:Static p:Resources.ColHeaderUpdatedOn}" Binding="{Binding DateRecordUpdated, StringFormat='dd/MM/yyyy'}" IsReadOnly="True"></DataGridTextColumn>


                            <!--<DataGridTextColumn Header="District of Residence" Binding="{Binding DistrictResidence}" IsReadOnly="True" />
                            
                            <DataGridTextColumn Header="Date of Onset" Binding="{Binding DateOnset, StringFormat='dd/MM/yyyy'}" IsReadOnly="True"></DataGridTextColumn>-->
                            <!--<DataGridTextColumn Binding="{Binding DateLastLabSampleCollected, StringFormat='dd/MM/yyyy'}" IsReadOnly="True">
                                <DataGridTextColumn.HeaderTemplate>
                                    <DataTemplate>
                                        <TextBlock>
                                        Date Last
                                    <LineBreak />
                                        Sample Collected
                                        </TextBlock>
                                    </DataTemplate>
                                </DataGridTextColumn.HeaderTemplate>
                            </DataGridTextColumn>-->
                            <!--<DataGridTextColumn Header="Sample Interpretation" Binding="{Binding LastSampleInterpretation}" IsReadOnly="True" />-->
                            <!--<DataGridTextColumn Header="PCR Result of Last Lab Sample" Binding="{Binding LastSamplePCRResult}" IsReadOnly="True" />-->
                        </DataGrid.Columns>
                    </DataGrid>
                           
                    <!--<Grid x:Name="grdRecordsHeader" Height="Auto">
                        <Grid.Resources>
                            <SolidColorBrush x:Key="textColorHeading" Color="#FF2E8BCC"></SolidColorBrush>
                        </Grid.Resources>

                        <Grid.RowDefinitions>
                            <RowDefinition Height="18" MaxHeight="18"></RowDefinition>
                            <RowDefinition Height="1" MaxHeight="1"></RowDefinition>
                        </Grid.RowDefinitions>

                        <Grid.ColumnDefinitions>
                            <ColumnDefinition SharedSizeGroup="A" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="B" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="C" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="D" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="E" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="F" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="G" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="H" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="I" Width="Auto"></ColumnDefinition>
                            <ColumnDefinition SharedSizeGroup="J" Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>

                        <TextBlock Grid.Row="0" Grid.Column="0" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">KEY</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="1" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">EPID</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="2" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">Surname</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="3" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">First Name</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="4" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">City</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="5" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">District</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="6" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">Age</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="7" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">Sex</TextBlock>
                        <TextBlock Grid.Row="0" Grid.Column="8" Foreground="{StaticResource textColorHeading}" HorizontalAlignment="Left" Margin="{StaticResource gridHeaderMargin}">Case Cls</TextBlock>

                        <StackPanel Grid.Column="0" Grid.ColumnSpan="10" Grid.Row="1" Background="{StaticResource textColorHeading}"></StackPanel>
                    </Grid>-->

                    <!--<ScrollViewer MaxHeight="400">
                        <Grid x:Name="grdRecords" Height="Auto">

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition SharedSizeGroup="A" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="B" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="C" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="D" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="E" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="F" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="G" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="H" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="I" Width="Auto"></ColumnDefinition>
                                <ColumnDefinition SharedSizeGroup="J" Width="Auto"></ColumnDefinition>
                            </Grid.ColumnDefinitions>
                        </Grid>
                    </ScrollViewer>-->
                </StackPanel>
            </Grid>
        </Grid>
        <!--</ScrollViewer>-->
    </Grid>
</UserControl>
